<template>
  <a-card :bordered="false">

    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item prop="serialNumber" label="任务名称">
              <a-input v-model="queryParam.approveName" allowClear placeholder="任务名称" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search" style="margin-right: 8px">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-right: 8px">重置</a-button>
              </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :pagination="ipagination"
        :dataSource="dataSource"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >

        <span slot="taskUrl" slot-scope="text, record">{{ getCheckData(record.taskUrl) }}</span>

        <span slot="action" slot-scope="text, record">
          <a @click="getPreviewImage(record)">流程图</a>
          <a-divider type="vertical" />
          <a @click="getApprovalList(record)">审批记录</a>
        </span>
      </a-table>
    </div>
    <image-modal ref="imageModal" />
    <approva-str ref="approvaStr"></approva-str>
  </a-card>
</template>

<script>
// 已经处理任务列表
  import '@/assets/less/TableExpand.less'
  import { getAction } from '@/api/manage'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   import { mixinDevice } from '@/utils/mixin'
   import ImageModal from '../apply/ImageModal'
   import ApprovaStr from '../apply/ApprovaStr'

  export default {
    name: 'ApprovalProcessedList',
    mixins: [JeecgListMixin, mixinDevice],
    components: {
      ImageModal, ApprovaStr
    },
    data () {
      return {
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '任务ID',
            align: 'center',
            dataIndex: 'id'
          },
          {
            title: '任务名称',
            align: 'center',
            dataIndex: 'approveName'
          },
          {
            title: '任务节点',
            align: 'center',
            dataIndex: 'taskNodeName'
          },
          {
            title: '流程KEY',
            align: 'center',
            dataIndex: 'processDefinitionKey'
          },
          {
            title: '表单KEY',
            align: 'center',
            dataIndex: 'taskUrl',
            scopedSlots: { customRender: 'taskUrl' }
          },
          {
            title: '审批时间',
            align: 'center',
            dataIndex: 'createTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: '/approval/task/list/processed',
          delete: '/apply/applyLeave/delete',
          deleteBatch: '/apply/applyLeave/deleteBatch',
          exportXlsUrl: '/apply/applyLeave/exportXls',
          importExcelUrl: '/apply/applyLeave/importExcel'
        },
        queryParam: {
           key: '',
           approveName: ''
        },
        loading: false
      }
    },
    created() {
    },
    computed: {
    },
    methods: {
      getCheckData(taskUrl) {
        let key = taskUrl.split('/')
        return key[0]
      },
      getPreviewImage(item) {
          this.$refs.imageModal.openModel(item)
      },
      getApprovalList(item) {
          this.$refs.approvaStr.openModel(item)
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .table-operator .ant-btn {
        margin: 3px 8px 4px 0;
    }
</style>
